home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1998 #4
/
Amiga Plus CD - 1998 - No. 4.iso
/
pd
/
disk
/
image2disk
/
image2disk.s
< prev
next >
Wrap
Text File
|
1998-02-18
|
31KB
|
1,002 lines
*****************************************************************************
* *
* PROGRAM: Image2Disk *
* VERSION: 1.0 *
* SOURCE CODE: 7 *
* DATE: 13.01. - 20.01.1998 *
* LANGUAGE: Assembler (DevPac V3.14) *
* SYSTEM: A1200 KS 40.68 WB 40.42 2MB chip 8MB fast 68030/50mhz *
* *
* AUTHOR: Joerg Riemer 14167 Berlin/SchottmuellerStr.107/Germany *
* EMAIL: mission@cs.tu-berlin.de *
* *
* COMMENT: there are two assembler conditions. *
* *
* 1.) BSS_Section: To get a shorter File, don't assemble *
* with BSS-section. Use StripHunk instead to generate *
* a Code_BSS-segment. it spares some bytes! but for *
* anybody don't know what this means: "leave it as it is" *
* *
* StripHunk is available at AmiNet dev/misc/... *
* *
* 2.) Verify_On: image2disk has an option to verify *
* written tracks when using [image --> disk]. if *
* this condition is set, track-verifying will be *
* executed by default. otherwise the flag must be *
* set by user. *
* *
* for suggestions, hints/tips, and/or questions *
* send an email to: mission@cs.tu-berlin.de *
* *
*****************************************************************************
BSS_Section set 1
Verify_On set 0
*****************************************************************************
output ram:Image2Disk
************************************************ exec definitions ***********
_LVOWaitPort equ -384
_LVOGetMsg equ -372
_LVOForbid equ -132
_LVOReplyMsg equ -378
_LVOOpenLibrary equ -552
_LVOCloseLibrary equ -414
_LVOOpenDevice equ -444
_LVOCloseDevice equ -450
_LVODoIO equ -456
_LVOCreateIORequest equ -654
_LVODeleteIORequest equ -660
_LVOCreateMsgPort equ -666
_LVODeleteMsgPort equ -672
pr_CLI equ $0AC
pr_MsgPort equ $05C
IOSTD_SIZE equ $030
************************************************ dos definitions ************
_LVOOpen equ -030
_LVOClose equ -036
_LVORead equ -042
_LVOWrite equ -048
_LVOSeek equ -066
_LVODeleteFile equ -072
_LVOLock equ -084
_LVOUnLock equ -090
_LVOCurrentDir equ -126
_LVOLockDosList equ -654
_LVOUnLockDosList equ -660
_LVOFindDosEntry equ -684
_LVOInhibit equ -726
OFFSET_END equ 001
OFFSET_BEGINNING equ -001
ACCESS_READ equ -002
LDF_READ equ $001
LDF_DEVICES equ $004
MODE_NEWFILE equ $3EE
MODE_OLDFILE equ $3ED
************************************************ reqtools definitions *******
_LVOrtAllocRequestA equ -030
_LVOrtFreeRequest equ -036
_LVOrtChangeReqAttrA equ -048
_LVOrtFileRequestA equ -054
_LVOrtEZRequestA equ -066
EZREQF_NORETURNKEY equ $001
EZREQF_CENTERTEXT equ $004
FREQF_PATGAD equ $010
FREQF_SAVE equ $002
rtfi_Dir equ $010
RT_TagBase equ $80000000
RTEZ_ReqTitle equ RT_TagBase+20
RTEZ_Flags equ RT_TagBase+22
RTFI_Flags equ RT_TagBase+40
RTFI_Dir equ RT_TagBase+50
RTFI_MatchPat equ RT_TagBase+51
************************************************ bss datas ******************
WBMsg rs.l 1 ;workbench message
DOSBase rs.l 1 ;ptr. base of dos
REQBase rs.l 1 ;ptr. base of reqtools
RCode rs.l 1 ;buffer for returncode
DLock rs.l 1 ;buffer (returned dir.-lock)
FLock rs.l 1 ;buffer (opened file_lock)
ToDo rs.l 1 ;ptr. (subroutine to do)
TList rs.l 1 ;ptr. taglist
ReqTitle rs.l 1 ;ptr. (title for filereq.)
MessagePort rs.l 1 ;ptr. msgport for doio()
IORequest rs.l 1 ;ptr. iorequest for doio()
FReqBase rs.l 1 ;ptr. (base of filerequester)
ArgArray1 rs.l 1 ;reqtools argarray
ArgArray2 rs.l 0 ;ptr. to devicename
Device rs.l 1 ;sometimes used for argarray
FileName rs.b 108 :room for filename
EFlag rs.b 1 ;error flag
DriveNum rs.b 1 ;buffer (unit number)
DriveChr rs.b 1 ;buffer for "D","F","H","V"
RWSwitch rs.b 1 ;flag (read or write track)
VFlag rs.b 1 ;verify-switch
rs.b 1 ;unused (for longword align)
rs.b 1 ;unused (for longword align)
rs.b 1 ;unused (for longword align)
TrackBuffer1 rs.b 512*11*2 ;for read/write tracks
TrackBuffer2 rs.b 512*11*2 ;for verify written tracks
BSS_Size rs.b 0 ;bss_size overall
OneTrack set BSS_Size-TrackBuffer2 ;standard track_size
************************************************ workbench startup **********
Start movem.l D1-D7/A0-A6,-(SP) ;save registers
if BSS_Section ;check assembler condition
movea.l Start-4(pc),A5 ;get bss_section
addq.l #1,A5 ;skip pointer (next segment)
adda.l A5,A5 ;convert bpcl_pointer
adda.l A5,A5 ;to real_address
elseif ;otherwise
lea DataBase(pc),A5 ;set working area
endc ;end condition
*****************************************************************************
movea.l 4.w,A6 ;set execbase
movea.l $114(A6),A2 ;find own task
tst.l pr_CLI(A2) ;we are from cli?
bne.b FromCLI ;branch if so
lea pr_MsgPort(A2),A0 ;set message port
jsr _LVOWaitPort(A6) ;wait for
lea pr_MsgPort(A2),A0 ;set message port
jsr _LVOGetMsg(A6) ;get wb_message
move.l D0,(A5) ;and save for later return
*****************************************************************************
FromCLI bsr.b OpenLibs
*****************************************************************************
tst.l (A5) ;launched from wb?
beq.b ExitDOS ;branch if not
movea.l 4.w,A6 ;set execbase
jsr _LVOForbid(A6) ;use exec to (forbid) tasks
movea.l (A5),A1 ;set wb_message
jsr _LVOReplyMsg(A6) ;use EXEC to (replymsg)
ExitDOS move.l RCode(A5),D0 ;set returncode
movem.l (SP)+,D1-D7/A0-A6 ;restore registers
rts ;go back (shell/wb)
*****************************************************************************
version dc.b "$VER: image2disk 1.0 (20.1.98) by joerg riemer jan'98",0
************************************************ open libraries *************
OpenLibs moveq #20,D0 ;preset returncode
move.l D0,RCode(A5) ;20 - library not found!
moveq #37,D0 ;required library version
lea DOSName(pc),A1 ;set library name
jsr _LVOOpenLibrary(A6) ;use EXEC to (openlibrary)
move.l D0,DOSBase(A5) ;save base
beq.b CloseLibs ;branch if not open
moveq #38,D0 ;required library version
lea REQName(pc),A1 ;set library name
jsr _LVOOpenLibrary(A6) ;use EXEC to (openlibrary)
move.l D0,REQBase(A5) ;save base
beq.b CloseLibs ;branch if not open
*****************************************************************************
bsr.b Main
************************************************ close libraries ************
CloseLibs movea.l 4.w,A6 ;set EXEC to call a function
move.l REQBase(A5),D1 ;get base_ptr
beq.b CloseDOS ;branch when not open
movea.l D1,A1 ;set base_ptr
jsr _LVOCloseLibrary(A6) ;use EXEC to (closelibrary)
CloseDOS move.l DOSBase(A5),D1 ;get base_ptr
beq.b QuitClose ;branch when not open
movea.l D1,A1 ;set base_ptr
jsr _LVOCloseLibrary(A6) ;use EXEC to (closelibrary)
QuitClose rts ;back to DOS
*****************************************************************************
DOSName dc.b "dos.library",0
REQName dc.b "reqtools.library",0,0
*****************************************************************************
Main moveq #0,D0 ;preset returncode
move.l D0,RCode(A5) ;00 - everything ok!
bsr AllocReq ;allocate file_requester
bsr InitReq ;change some attributes
bsr.b SetDevChr ;set device_characters
************************************************
if Verify_On ;check assembler condition
bsr.b Verify ;verify -> default = vflag on
elseif ;otherwise
bsr.b Loop ;loop -> default = vflag off
endc ;end condition
************************************************
bsr FreeReq ;free file_requester
rts ;go back
************************************************ edit main requester text ***
SetDevChr moveq #3,D0 ;set loop_counter
lea ChrTable(pc),A0 ;set character table
lea Text22(pc),A1 ;set text to edit
SetChr move.l D0,D1 ;prepare text_offset
lsl #3,D1 ;prepare text_offset
add D0,D1 ;prepare text_offset
move.b 1(A0,D0.w),(A1,D1.w) ;edit requester text
dbra D0,SetChr ;do it 4 times
rts ;go back
*****************************************************************************
ChrTable dc.b 0,"DFHV",0 ;device_characters
*****************************************************************************
Verify eor.b #$1,VFlag(A5) ;change verify_flag
lea Text13(pc),A0 ;get text
eor.b #$A,$A(A0) ;change text also
*********************** print main request *****
Loop lea TList1(pc),A0 ;set taglist
lea Text12(pc),A1 ;set requester_text
lea Text13(pc),A2 ;set gadget_text
bsr REQuest0 ;and request by reqtools
tst.b D0 ;test for [quit] by user
beq Quit ;branch if so
subq #1,D0 ;check for verify
beq.b Verify ;branch if so
lea ReadFile(pc),A0 ;get read file / write disk
lea TList3(pc),A1 ;get filerequester taglist
lea Text03(pc),A2 ;get filerequester title
subq #1,D0 ;want to write a disk?
sne RWSwitch(A5) ;set switch (read or write)
beq.b SetToDo ;branch if so
lea WriteFile(pc),A0 ;get write file / read disk
lea TList4(pc),A1 ;get filerequester taglist
lea Text04(pc),A2 ;get filerequester title
SetToDo move.l A0,ToDo(A5) ;save jump_in
move.l A1,TList(A5) ;save taglist
move.l A2,ReqTitle(A5) ;save title
*********************** ask for device *********
lea TList1(pc),A0 ;set taglist
lea Text21(pc),A1 ;set requester_text
lea Text22(pc),A2 ;set gadget_text
bsr REQuest0 ;and request by reqtools
move.b ChrTable(pc,D0),DriveChr(A5) ;get drive_character
beq.b Loop ;branch if canceled
lea Device1(pc),A0 ;get fmsdisk.device
subq #1,D0 ;check for trackdisk
bne.b SetDevice ;or fmsdisk.device
lea Device0(pc),A0 ;get trackdisk.device
SetDevice move.l A0,Device(A5) ;save devicename
*********************** ask for unit ***********
lea Text24(pc),A2 ;set gadget_text
moveq #3,D0 ;set loop_counter
SetChar move.l D0,D1 ;prepare offset
lsl.l #2,D1 ;prepare offset
move.b DriveChr(A5),(A2,D1.W) ;edit text
dbra D0,SetChar ;do it 4 times
lea TList1(pc),A0 ;set taglist
lea Text23(pc),A1 ;set requester_text
bsr REQuest0 ;ask user for drive_number
subq #1,D0 ;prepare drive_number
bmi Loop ;branch if canceled
move.b D0,DriveNum(A5) ;save drive_number
lea Text99(pc),A0 ;get text to prepare
move.b DriveChr(A5),(A0) ;edit text
addi.b #$30,D0 ;drive_number -> ASCII
move.b D0,2(A0) ;edit text
************************************************
st EFlag(A5) ;preset error_flag
moveq #0,D0 ;preset returncode
move.l D0,RCode(A5) ;00 - everything ok!
************************************************
bsr.b CreateIOReq ;create msgport/iorequest
bsr OpenDevice ;open required device
bsr GetFileName ;get image_filename
bsr GetCDir ;change currentdir
movea.l ToDo(A5),A0 ;get subroutine
jsr (A0) ;read disk / write disk
bsr ResetCDir ;restore previous path
ReqFail0 bsr CloseDevice ;close track./fmsdisk.device
ReqFail1 bsr.b DeleteIOReq ;remove iorequest/msgport
************************************************
ReqFail2 lea Text94(pc),A4 ;set insert = successful
tst.b EFlag(A5) ;test error_flag
beq.b .Ready ;branch if ok
lea Text96(pc),A4 ;set insert = canceled
tst.l RCode(A5) ;test returncode
beq.b .Ready ;branch if ok
lea Text95(pc),A4 ;set insert = failed
.Ready move.l A4,ArgArray1(A5) ;save ptr.
lea ArgArray1(A5),A4 ;set argarray
lea TList0(pc),A0 ;set taglist
lea Text41(pc),A1 ;set requester_text
lea Text42(pc),A2 ;set gadget_text
bsr REQuest0 ;ask user for [quit]
tst.b D0 ;another image_transfer?
bne Loop ;branch if so
Quit rts ;else, go back (quit program)
************************************************ create msgeport/iorequest **
CreateIOReq movea.l 4.w,A6 ;set EXEC to use a function
jsr _LVOCreateMsgPort(A6) ;use EXEC to (createport)
move.l D0,MessagePort(A5) ;save ptr.
beq Error09 ;branch when failed
moveq #IOSTD_SIZE,D0 ;iorequest size
movea.l MessagePort(A5),A0 ;set msgport
jsr _LVOCreateIORequest(A6) ;use EXEC to (createrequest)
move.l D0,IORequest(A5) ;save ptr.
beq Error10 ;branch when failed
rts ;go back
************************************************ delete iorequest/msgport ***
DeleteIOReq movea.l 4.w,A6 ;set EXEC to use a function
movea.l IORequest(A5),A0 ;set iorequest
jsr _LVODeleteIORequest(A6) ;use EXEC to (deleterequest)
movea.l MessagePort(A5),A0 ;set msgport
jsr _LVODeleteMsgPort(A6) ;use EXEC to (deletemsgport)
rts ;go back
************************************************ finddosentry / opendevice **
OpenDevice moveq #5,D1 ;flags (ldf_devices|ldf_read)
movea.l DOSBase(A5),A6 ;set DOS to call a function
jsr _LVOLockDosList(A6) ;use DOS to (lockdoslist)
move.l D0,D1 ;set dlist
lea Text99(pc),A2 ;get drivename
move.b #0,3(A2) ;prepare drivename
move.l A2,D2 ;set drivename
moveq #LDF_DEVICES,D3 ;control flag (devices only)
jsr _LVOFindDosEntry(A6) ;use DOS to (finddosentry)
move.l D0,D2 ;save entry
move.b #":",3(A2) ;reset drivename
moveq #5,D1 ;flags (ldf_devices|ldf_read)
jsr _LVOUnLockDosList(A6) ;use DOS to (unlockdoslist)
tst.l D2 ;device_node found ?
beq Error11 ;branch if not
*********************** compare devicename *****
movea.l D2,A2 ;set node
movea.l $1C(A2),A2 ;get dn_startup
adda.l A2,A2 ;convert bcpl_ptr.
adda.l A2,A2 ;to real address
movea.l 4(A2),A0 ;get fssm_device
adda.l A0,A0 ;convert bcpl_ptr.
adda.l A0,A0 ;to real address
move.b (A0)+,D0 ;set string_length
ext.w D0 ;prepare loop_counter
subq #1,D0 ;prepare loop_counter
movea.l Device(A5),A1 ;set expected device
CheckDevice cmpm.b (A0)+,(A1)+ ;compare device_name
bne Error12 ;branch on error
dbra D0,CheckDevice ;do for all characters
*********************** check drive geometry ***
lea DriveGeometry(pc),A0 ;get drive geometry
movea.l 8(A2),A1 ;get fssm_environ
adda.l A1,A1 ;convert bcpl_ptr.
adda.l A1,A1 ;to real address
move.l (A0)+,D0 ;get bytes per block
cmp.l $04(A1),D0 ;check for
bne Error13 ;branch if not equal
move.l (A0)+,D0 ;get surfaces
cmp.l $0C(A1),D0 ;check for
bne Error13 ;branch if not equal
move.l (A0)+,D0 ;get blocks per track
cmp.l $14(A1),D0 ;check for
bne Error13 ;branch if not equal
move.l (A0)+,D0 ;get first track
cmp.l $24(A1),D0 ;check for
bne Error13 ;branch if not equal
move.l (A0)+,D0 ;get last track
cmp.l $28(A1),D0 ;check for
bne Error13 ;branch if not equal
*********************** open device ************
moveq #0,D0 ;prepare register
moveq #0,D1 ;set flags
move.b DriveNum(A5),D0 ;set drive_number
movea.l Device(A5),A0 ;set devicename
movea.l IORequest(A5),A1 ;set iorequest
movea.l 4.w,A6 ;set EXEC to call a function
jsr _LVOOpenDevice(A6) ;use EXEC to (opendevice)
tst.l D0 ;everything ok?
bne Error05 ;branch if not
rts ;go back
*****************************************************************************
DriveGeometry dc.l $00000080 ;longs per block
dc.l $00000002 ;surfaces per disk
dc.l $0000000B ;blocks per track
dc.l $00000000 ;first cylinder
dc.l $0000004F ;last cylinder
************************************************ close device / remove port *
CloseDevice movea.l 4.w,A6 ;set EXEC to call a function
movea.l IORequest(A5),A1 ;set iorequest
jsr _LVOCloseDevice(A6) ;use EXEC to (closedevice)
rts ;go back
************************************************ read disk / write image ****
WriteFile lea FileName(A5),A1 ;get filename
move.l A1,D1 ;set filename
move.l #MODE_NEWFILE,D2 ;set options
movea.l DOSBase(A5),A6 ;set DOS to call a function
jsr _LVOOpen(A6) ;use DOS to (open) file
move.l D0,FLock(A5) ;save lock
beq Error06 ;branch when failed
*********************** read tracks ************
bsr Inhibit ;inhibit drive
bsr REQInsert ;request (insert disk)
move.l #OneTrack,D5 ;set track length
moveq #00000000,D6 ;prepare track_offset
moveq #79,D7 ;prepare loop_counter
ReadTracks lea TrackBuffer1(A5),A2 ;get track_buffer
movea.l IORequest(A5),A1 ;get io_request
move.w #2,$1C(A1) ;set io_command (cmd_read)
move.l D5,$24(A1) ;set io_length
move.l A2,$28(A1) ;set buffer
move.l D6,$2C(A1) ;set track_offset
movea.l 4.w,A6 ;set EXEC to call a function
jsr _LVODoIO(A6) ;use EXEC for (doio)
tst.l D0 ;check for success
bne Error07 ;branch if not
move.l FLock(A5),D1 ;set file_lock
move.l A2,D2 ;set buffer
move.l D5,D3 ;set length to write
movea.l DOSBase(A5),A6 ;set DOS to call a function
jsr _LVOWrite(A6) ;use DOS to (write) bytes
cmp.l D0,D3 ;something wrong?
bne Error08 ;branch if so
add.l D5,D6 ;add track
dbra D7,ReadTracks ;and do the next one
sf EFlag(A5) ;clear error_flag (ok)
bra InitDrive ;close file / reset drive
************************************************ read image / write disk ****
ReadFile lea FileName(A5),A1 ;get filename
move.l A1,D1 ;set filename
move.l #MODE_OLDFILE,D2 ;set options
movea.l DOSBase(A5),A6 ;set DOS to call a function
jsr _LVOOpen(A6) ;use DOS to (open) file
move.l D0,FLock(A5) ;save lock
beq Error00 ;branch if not found
move.l FLock(A5),D1 ;set file_lock
moveq #0,D2 ;set position
moveq #OFFSET_END,D3 ;set mode
jsr _LVOSeek(A6) ;use DOS to (seek) in file
move.l FLock(A5),D1 ;set file_lock
moveq #0,D2 ;set position
moveq #OFFSET_BEGINNING,D3 ;set mode
jsr _LVOSeek(A6) ;use DOS to (seek) in file
cmpi.l #$DC000,D0 ;must be the file_length!!
bne Error01 ;branch if not
************************ write tracks **********
bsr Inhibit ;inhibit drive
bsr REQInsert ;request (insert disk)
move.l #OneTrack,D5 ;set track length
moveq #00000000,D6 ;prepare track_offset
moveq #79,D7 ;prepare loop_counter
WriteTracks lea TrackBuffer1(A5),A2 ;get track_buffer
move.l FLock(A5),D1 ;set file_lock
move.l A2,D2 ;set buffer
move.l D5,D3 ;set length to read
movea.l DOSBase(A5),A6 ;set DOS to call a function
jsr _LVORead(A6) ;use DOS to (read) some bytes
cmp.l D0,D3 ;something wrong?
bne Error02 ;branch if so
movea.l IORequest(A5),A1 ;get io_request
move.w #$B,$1C(A1) ;set io_command (cmd_format)
move.l D5,$24(A1) ;set io_length
move.l A2,$28(A1) ;set buffer
move.l D6,$2C(A1) ;set track_offset
movea.l 4.w,A6 ;set EXEC to call a function
jsr _LVODoIO(A6) ;use EXEC for (doio)
tst.l D0 ;check for success
bne Error03 ;branch if not
************************ verify track **********
tst.b VFlag(A5) ;want to verify ?
beq.b WriteNext ;branch if not
lea TrackBuffer2(A5),A2 ;get track_buffer
movea.l IORequest(A5),A1 ;get io_request
move.w #2,$1C(A1) ;set io_command (cmd_read)
move.l D5,$24(A1) ;set io_length
move.l A2,$28(A1) ;set buffer
move.l D6,$2C(A1) ;set track_offset
movea.l 4.w,A6 ;set EXEC to call a function
jsr _LVODoIO(A6) ;use EXEC for (doio)
tst.l D0 ;check for success
bne Error04 ;branch if not
lea TrackBuffer1(A5),A0 ;get track_buffer
lea TrackBuffer2(A5),A1 ;get track_buffer
move.l #OneTrack/4-1,D0 ;set loop_counter
VerifyTrack cmpm.l (A0)+,(A1)+ ;compare buffers
bne Error04 ;branch if fails
dbra D0,VerifyTrack ;do it sometimes
************************************************
WriteNext add.l D5,D6 ;add track
dbra D7,WriteTracks ;and do the next one
sf EFlag(A5) ;clear error_flag (ok)
************************************************ init. drive / close file ***
InitDrive lea Text99(pc),A1 ;get drive
move.l A1,D1 ;set drive
moveq #0,D2 ;set flag (uninhibit)
movea.l DOSBase(A5),A6 ;set DOS to call a function
jsr _LVOInhibit(A6) ;use DOS to (inhibit)
************************************************
CloseFile move.l FLock(A5),D1 ;set file_lock
movea.l DOSBase(A5),A6 ;set DOS to call a function
jsr _LVOClose(A6) ;use DOS to (close) file
************************************************
tst.b RWSwitch(A5) ;read file ?
beq.b .Ready ;branch if so
tst.b EFlag(A5) ;test for error
beq.b .Ready ;branch if not
lea FileName(A5),A1 ;get filename
move.l A1,D1 ;set filename
jsr _LVODeleteFile(A6) ;use DOS to (deletefile)
************************************************
.Ready rts ;go back
*****************************************************************************
Inhibit lea Text99(pc),A1 ;get drive
move.l A1,D1 ;set drive
moveq #-1,D2 ;set flag (inhibit)
movea.l DOSBase(A5),A6 ;set DOS to call a function
jsr _LVOInhibit(A6) ;use DOS to (inhibit)
tst.l D0 ;check for inhibit
bne.b .Ready ;branch if so
lea TList0(pc),A0 ;set taglist
lea Text53(pc),A1 ;set requester_text
lea Text54(pc),A2 ;set gadget_text
lea Text99(pc),A3 ;get drivename
lea Text31(pc),A4 ;get req_title #2
move.l A4,ArgArray1(A5) ;save ptr.
move.l A3,ArgArray2(A5) ;save ptr.
lea ArgArray1(A5),A4 ;set argarray
bsr REQuest0 ;and request by reqtools
tst.l D0 ;check for [retry]
bne.b Inhibit ;branch if so
moveq #1,D0 ;set returncode
move.l D0,RCode(A5) ;01 - drive in use
addq #4,SP ;clear return_address
pea CloseFile(pc) ;set new one
.Ready rts ;go back / go loop
************************************************ request (insert disk) ******
REQInsert lea TList0(pc),A0 ;set taglist
lea Text51(pc),A1 ;set requester_text
lea Text52(pc),A2 ;set gadget_text
lea Text99(pc),A4 ;get string
move.l A4,ArgArray1(A5) ;save ptr.
lea ArgArray1(A5),A4 ;set argarray
bsr REQuest0 ;and request by reqtools
tst.l D0 ;check for [cancel]
bne.b .Ready ;branch if so
addq #4,SP ;clear return_address
pea InitDrive(pc) ;set new one
.Ready rts ;go back
************************************************ error report (createport) **
Error10 movea.l MessagePort(A5),A0 ;set msgport
jsr _LVODeleteMsgPort(A6) ;use EXEC to (deleteport)
Error09 moveq #9,D0 ;set returncode - noport
lea Text37(pc),A1 ;set requester_text
addq #4,SP ;clear return_address
pea ReqFail2(pc) ;set new one
bra REQuest1 ;request error
************************************************ error report (writefile) ***
Error06 moveq #4,D0 ;set returncode - open()
lea Text34(pc),A1 ;set requester_text
bra REQuest1 ;request error
Error07 moveq #3,D0 ;set returncode - doio()
lea Text36(pc),A1 ;set requester_text
lea Text91(pc),A3 ;set insert_text
move.l A3,ArgArray2(A5) ;save ptr. (insert #2)
bra REQuest2 ;request error
Error08 moveq #2,D0 ;set returncode - write()
lea Text35(pc),A1 ;set requester_text
lea Text92(pc),A3 ;set insert_text
move.l A3,ArgArray2(A5) ;save ptr. (insert #2)
bra.b REQuest2 ;request error
************************************************ error report (opendevice) **
Error11 moveq #11,D0 ;set rcode - no dosentry
lea Text61(pc),A1 ;set requester_text
bra.b REQuest4 ;request error
Error12 moveq #12,D0 ;set rcode - unexpected dev.
lea Text62(pc),A1 ;set requester_text
bra.b REQuest4 ;request error
Error13 moveq #13,D0 ;set rcode - wrong geometry
lea Text63(pc),A1 ;set requester_text
bra.b REQuest4 ;request error
Error05 moveq #10,D0 ;set rcode - opendevice()
lea Text32(pc),A1 ;set requester_text
bra.b REQuest3 ;request error
*****************************************************************************
REQuest4 lea Text99(pc),A3 ;set insert_text
move.l A3,ArgArray2(A5) ;save ptr. (insert #2)
REQuest3 addq #4,SP ;clear return_address
pea ReqFail1(pc) ;set new one
bra.b REQuest1 ;request error
************************************************ error report (readfile) ****
Error00 moveq #5,D0 ;set returncode - open()
lea Text34(pc),A1 ;set requester_text
bra.b REQuest1 ;request error
Error01 moveq #6,D0 ;set returncode - seek()
lea Text33(pc),A1 ;set requester_text
pea CloseFile(pc) ;set return_address
bra.b REQuest1 ;request error
Error02 moveq #7,D0 ;set returncode - read()
lea Text35(pc),A1 ;set requester_text
lea Text91(pc),A3 ;set insert_text
move.l A3,ArgArray2(A5) ;save ptr. (insert #2)
bra.b REQuest2 ;request error
Error03 moveq #8,D0 ;set returncode - doio()
lea Text36(pc),A1 ;set requester_text
lea Text92(pc),A3 ;set insert_text
move.l A3,ArgArray2(A5) ;save ptr. (insert #2)
bra.b REQuest2 ;request error
Error04 moveq #8,D0 ;set returncode - doio()
lea Text36(pc),A1 ;set requester_text
lea Text93(pc),A3 ;set insert_text
move.l A3,ArgArray2(A5) ;save ptr. (insert #2)
* bra.b REQuest2 ;request error
REQuest2 pea InitDrive(pc) ;set return_address
************************************************ open error_requester *******
REQuest1 move.l D0,RCode(A5) ;set returncode
lea TList0(pc),A0 ;set taglist
lea Text39(pc),A2 ;set gadget_text
lea Text31(pc),A4 ;get req_title #2
move.l A4,ArgArray1(A5) ;save ptr.
lea ArgArray1(A5),A4 ;set argarray
REQuest0 suba.l A3,A3 ;no reqinfo
movea.l REQBase(A5),A6 ;set REQ to call a function
jsr _LVOrtEZRequestA(A6) ;use REQ for (easyrequest)
rts ;go back
************************************************ alloc file_requester *******
AllocReq moveq #0,D0 ;want file_requester
suba.l A0,A0 ;no tags yet
movea.l REQBase(A5),A6 ;set REQ to call a function
jsr _LVOrtAllocRequestA(A6) ;use REQ to (allocrequest)
move.l D0,FReqBase(A5) ;save base
bne.b .Ready ;branch if ok
moveq #15,D0 ;set returncode
move.l D0,RCode(A5) ;15 - no file_requester
addq #4,SP ;clear return_address
.Ready rts ;go back / quit program
************************************************ change request attributes **
InitReq lea TList0(pc),A0 ;for pos. independent code
lea Text11(pc),A1 ;for pos. independent code
move.l A1,4(A0) ;for pos. independent code
lea TList1(pc),A0 ;for pos. independent code
move.l A1,4(A0) ;for pos. independent code
lea TList2(pc),A0 ;for pos. independent code
lea Text01(pc),A1 ;for pos. independent code
move.l A1,4(A0) ;for pos. independent code
lea Text02(pc),A1 ;for pos. independent code
move.l A1,12(A0) ;for pos. independent code
movea.l FReqBase(A5),A1 ;set file_requester
movea.l REQBase(A5),A6 ;set REQ to call a function
jsr _LVOrtChangeReqAttrA(A6) use REQ to (changereqattr)
rts ;go back
************************************************ close file_requester *******
FreeReq movea.l FReqBase(A5),A1 ;set file_requester
movea.l REQBase(A5),A6 ;set REQ to call a function
jsr _LVOrtFreeRequest(A6) ;use REQ to (freerequest)
rts ;go back
************************************************ open file_requester ********
GetFileName movea.l TList(A5),A0 ;set taglist
movea.l FReqBase(A5),A1 ;set file_requester
lea FileName(A5),A2 ;set buffer for filename
movea.l ReqTitle(A5),A3 ;set requester_title
movea.l REQBase(A5),A6 ;set REQ to call a function
jsr _LVOrtFileRequestA(A6) ;use REQ for (filerequest)
tst.l D0 ;check for user input
bne.b .Ready ;branch if set
addq #4,SP ;clear return_address
pea ReqFail0(pc) ;set new one
.Ready rts ;go back
************************************************ set and reset current dir **
GetCDir movea.l FReqBase(A5),A1 ; get FREQBase
move.l rtfi_Dir(A1),D1 ; set pathname
moveq #ACCESS_READ,D2 ; set mode
movea.l DOSBase(A5),A6 ; set DOS to use a function
jsr _LVOLock(A6) ; use DOS to (lock) directory
move.l D0,D1 ; set directory lock
jsr _LVOCurrentDir(A6) ; use DOS to set (currentdir)
move.l D0,DLock(A5) ; save prev. directory lock
rts ; go back
************************************************
ResetCDir move.l DLock(A5),D1 ; set prev. directory lock
movea.l DOSBase(A5),A6 ; set DOS to use a function
jsr _LVOCurrentDir(A6) ; use DOS to set (currentdir)
move.l D0,D1 ; set returned lock
jsr _LVOUnLock(A6) ; use DOS to (unlock) dir.
rts ; go back
*****************************************************************************
TList0 dc.l RTEZ_ReqTitle,0,RTEZ_Flags,EZREQF_CENTERTEXT,0
TList1 dc.l RTEZ_ReqTitle,0,RTEZ_Flags,EZREQF_CENTERTEXT!EZREQF_NORETURNKEY,0
TList2 dc.l RTFI_Dir,0,RTFI_MatchPat,0,0
TList3 dc.l RTFI_Flags,FREQF_PATGAD,0
TList4 dc.l RTFI_Flags,FREQF_PATGAD!FREQF_SAVE,0
*****************************************************************************
Device0 dc.b "trackdisk.device",0
Device1 dc.b "fmsdisk.device",0
Text01 dc.b "RAM:",0
Text02 dc.b "(#?.dim|#?.adf|#?)",0
Text03 dc.b "Read Image from...",0
Text04 dc.b "Save Image as...",0
Text11 dc.b "Image2Disk V1.0",0
Text12 dc.b "IMAGE-FILE --> DISK --> IMAGE-FILE",$A
dc.b "----------------------------------------------",$A
dc.b "for all standard diskdrives 880/KB",$A
dc.b "controlled either by the trackdisk.- or fmsdisk.device",$A
dc.b "--------------------------------------------------------",$A
dc.b "written by Joerg Riemer jan'98",$A
dc.b "email: mission@cs.tu-berlin.de",0
Text13 dc.b " Verify [ ] |Image --> Disk|Disk --> Image| Quit ",0
Text21 dc.b "Select Device",0
Text22 dc.b "DFx Unit|DFx Unit|DFx Unit|DFx Unit| Cancel ",0
Text23 dc.b "Select Unit",0
Text24 dc.b "DF0|DF1|DF2|DF3|Cancel",0
Text31 dc.b "ERROR!!!",0
Text32 dc.b "%s",$A,"Can't open %s for suggested drive.",0
Text33 dc.b "%s",$A,"Required length of Image-File is wrong.",0
Text34 dc.b "%s",$A,"Can't open suggested Image-File.",0
Text35 dc.b "%s",$A,"While %s Image-File.",0
Text36 dc.b "%s",$A,"While %s track.",0
Text37 dc.b "%s",$A,"Can't create MsgPort/IORequest!!",$A,"Please, try to free some memory.",0
Text61 dc.b "%s",$A,"Can't find %s",$A,"(suggested drive not mounted)",0
Text62 dc.b "%s",$A,"%s controlled by an unexpected device.",0
Text63 dc.b "%s",$A,"Drive-Geometry used by %s not supported.",0
Text39 dc.b " Cancel ",0
Text41 dc.b "Image-File transfer %s",0
Text42 dc.b " Get another one | Quit ",0
Text51 dc.b "Insert disk in drive %s",$A
dc.b "Click [Ok] or press <RETURN> to continue...",0
Text52 dc.b " Ok | Cancel ",0
Text53 dc.b "%s",$A,"Can't access %s",$A,"(suggested drive in use)",0
Text54 dc.b " Retry | Cancel ",0
Text91 dc.b "reading",0
Text92 dc.b "writing",0
Text93 dc.b "verifying",0
Text94 dc.b "successful!!!",0
Text95 dc.b "failed!!!",0
Text96 dc.b "canceled by user!!!",0
Text99 dc.b "DF0:",0
*****************************************************************************
if BSS_Section
SECTION Image2Disk_bss,BSS
elseif
cnop 0,4
endc
*****************************************************************************
DataBase ds.b BSS_Size
end of source **************************************************************